package com.chhuang.bean;

import com.chhuang.core.valid.ValidationGroups;
import com.chhuang.utils.string.RegexpUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * @ClassName RegeditBean
 * @Description 用于注册用户实体类
 * @Author Darren Huang
 * @Date 2022/11/19 20:57
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "RegeditAccountBean实体类", description = "用于注册用户实体类")
public class RegeditAccountBean implements Serializable {
    private static final long serialVersionUID = -6131278519375255021L;

    /**
     * 用户名
     * public String register(@Validated(ValidationGroups.RegeditGroup.class) @RequestBody User user)
     */
    @NotBlank(message = "{username.not_blank}")
    @Length(min = 1, max = 16, message = "{username.over_max_len}")
    @ApiModelProperty(value = "用户名", required = true)
    private String username;

    /**
     * 密码
     */
    @NotBlank(message = "{password.not_blank}")
    @Pattern(regexp=RegexpUtils.PASSWORD_WITH_NUM_AND_LET_SYM, message = "{password.valid_fail}")
    @ApiModelProperty(value = "密码", required = true)
    private String password;

    /**
     * 昵称
     */
    @Length(min = 0, max = 16, message = "{nickname.over_max_len}")
    @ApiModelProperty(value = "昵称")
    private String nickname;

    /**
     * 姓
     */
    @ApiModelProperty(value = "姓")
    private String lastname;

    /**
     * 名
     */
    @ApiModelProperty(value = "名")
    private String firstname;

    /**
     * 性别：男1，女0
     */
    @ApiModelProperty(value = "性别：男1，女0")
    private Byte gender;

    /**
     * 手机号
     */
    @NotBlank(message = "{phone.not_blank}")
    @Pattern(regexp = RegexpUtils.MOBILE_PHONE_REGEXP, message = "{phone.valid_fail}")
    @ApiModelProperty(value = "手机号", required = true)
    private String phone;

    /**
     * 电子邮箱号
     */
    @NotBlank(message = "{email.not_blank}")
    @Pattern(regexp = RegexpUtils.EMAIL_REGEXP, message = "{email.valid_fail}")
    @ApiModelProperty(value = "电子邮箱号", required = true)
    private String email;

    /**
     * 头像
     */
    @ApiModelProperty(value = "头像")
    private String photo;

    /**
     * 验证码
     */
    @Valid //这里需要做嵌套校验
    @ApiModelProperty(value = "验证码对象", required = true)
    private CaptchaBean captchaBean;
}
